package org.example

import com.sun.org.apache.xerces.internal.impl.dv.xs.StringDV
import scala.io.Source
import scala.io.{Source, StdIn}
import java.io.File
import java.io.PrintWriter

object helloScala {
  def main(args: Array[String]): Unit = {


    var name = "nazha"
    println(name)
    var arr: Array[String] = Array("spark", "scala", "java", "python")
    println(arr.mkString("Array(", ", ", ")"))
    arr.foreach(println)
    class Phone(color: String, var price: Int, isOpen: Boolean) {
      def printInfo(): Unit = {
        println(color + " " + price + " " + isOpen + " ")
        println(s"该手机颜色是$color,价格是$price,手机是$isOpen")
      }
    }
    var xiaomi = new Phone("white", 1299, true)
    xiaomi.printInfo()

    //    println("请输入接头暗号：")
    //    var word: String = StdIn.readLine()
    //    if (word == "好好学习") {
    //      println("正确！")
    //    } else {
    //      println("错误")
    //    }
    def sayHello(name: String): Unit = {
      println("hello" + name)

    }

    sayHello("小哪吒")
    helloScala.sayhi("哪吒2")
    val result = helloScala.Pi()
    println(result)
    Source.fromFile("src/main/rescourse/word.txt").foreach(print)
    val writer = new PrintWriter(new File("src/main/rescourse/word.txt"))
    writer.write("hello scala from java writer！")
    writer.close()








    //    println("hello scala!")
    //
    //    //  for (int i =0;i<10;i++)
    //    for (i <- 1 to 10) {
    //      print(i)
    //    }
    //    for (i <- 1.to(10)) {
    //      print(i)
    //    }
    //    for (i <- 1 until (10)) {
    //      print(i)
    //    }
    //    println("-----------------")
    //    for (i <- 1 to 10) {
    //      for (j <- 1 to 10) {
    //        print(i * j + "\n")
    //      }
    //    }
    //      for (i <- 1 to 9; j <- 1 to i) {
    //        print(i + "*" + j + '=' + i * j + "\t")
    //        if (i == j)
    //          println()
    //      }

  }

  def sayhi(name: String): Unit = {
    println("hi," + name)
  }

  def Pi(): Double = {
    println("圆周率计算出来的值是：")
    return 3.14
  }

}
